#include<iostream>
#include<set>
#include<string>
#include<sstream>
#include<limits>

using std::cout;
using std::endl;
using std::cin;
using std::set;
using std::string;

int main(void)
{
    int num1;
    int num2;
    cout<<"输入"<<endl;
    cin>>num1>>num2;
    cin.clear();
    cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
    set<int>A;

    set<int>B;

    string line;
    string line1;

    cout<<"the first"<<endl;
    std::getline(cin,line);
    std::istringstream iss (line);
    cout<<"the second"<<endl;
    std::getline(cin,line1);
    std::istringstream iss1 (line1);
    int num = num1>num2? num1:num2;

    for(int i =0;i<num;i++)
    {
        string a;
        if(i<num1&&i<num2)
        {
            iss>>a;
            A.insert(atoi(a.data()));

            a.clear();
            iss1>>a;
            B.insert(atoi(a.data()));
        }
        else 
        {
            if(i<num2)
            {
            iss1>>a;
            B.insert(atoi(a.data()));
            }
            else 
            {
            iss>>a;
            A.insert(atoi(a.data()));
            }
        }
    }
    A.insert(B.begin(),B.end());
    for(auto & i:A)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
